﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Mobile.Models.ArticleViewModel>" %>
<%@ Import Namespace = "SDT.Lib.Paging" %>
<%@ Import Namespace = "SDT.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="mar_top">
        <form action="/Article/Index" method="post">
            <input type="text" name="Articlename" value="<%=ViewData["articlenam"] %>" />
            <%=Html.DropDownList("ddlArticleCategory", new SelectList(Model.ArticleCategorys, "ID", "Name", ViewData["aticlecat"]), "-- Chọn danh mục --", new { })%>
            <label>&nbsp;</label><input type="submit" value="" class="btn" />
        </form>
    </div>
    <br />
    <div class="tit_bg"><strong> Tin tức</strong><%=Convert.ToInt32(ViewData["aticlecat"]) >0 ? " - "+ Model.ArticleCategorys.Where(e => e.ID == Convert.ToInt32(ViewData["aticlecat"])).Select(e => e.Name).FirstOrDefault().ToString() : ""%> </div>
 <%if (Model.Articlepage.Count == 0){ %>
   <div class="tit_new">Không tìm thấy kết quả nào</div>
 <%} else { %>
<%
    var c = 0;
    foreach (var item in Model.Articlepage)
    {
        string imgPath = (item.ImagePath != null && item.ImagePath != string.Empty && item.ImagePath.Trim().Length > 0) ? SDT.Lib.Common.Utils.GenThumbnail(item.ID, 61, 52, item.ImagePath, Model.ImagePath, Model.ImageUrl) : Model.DefaultUrl;
        if (c < 6)
        {   
%>
    <div class="cate_news">
        	<ul>
            	<li>
                	<div class="tit_img">
                	    <%=Html.CustomActionImage(item.Title, item.ArticleCategory.Name, "article", "details", new Dictionary<string, object>() { { "id", item.ID } }, "bor_img", string.Empty, 61, 51, imgPath)%>
                	    </div>
       				<div class="tit_cnt">
                        <div>
                                »»<%=Html.CustomActionLink(item.Title, item.ArticleCategory.Name, "article", "details", new Dictionary<string, object>() { { "id", item.ID } }, true, "l_blue")%>
                            </div>
                        <div><%= item.AddDate.ToString("MMM dd, yyyy")%></div>
                        <div><%= item.Summary%>... </div>
     			 	</div>
                    <div class="clear"></div>
                </li>
           </ul>
    </div>
<%   c++;
        }
        else { break; }
    }  
  %> 
  <div class="tit_bg"><strong> Các tin khác</strong></div>
  <% 
     c = 1;
     foreach (var item in Model.Articlepage)
     {
         if (c <= 6) { c++; }
         else
                {
      %>
      <div class="cate_news_other">
        »»<%=Html.CustomActionLink(item.Title, item.ArticleCategory.Name, "article", "details", new Dictionary<string, object>() { {"id",item.ID}},true,"l_blue")%>
        (<%= item.AddDate.ToString("MMM dd, yyyy")%>)
      </div>
   <%        
      }
     }             
 } %>
 
 	<div class="bg_paging">
        	<div class="continue"><a href="#" class="ctn">»»Xem tiếp</a></div>
        	<div class="pages_none" id="pages_none">
                <span><%= Html.Pager(Model.Articlepage.PageSize, Model.Articlepage.PageNumber, Model.Articlepage.TotalItemCount)%></span>
            </div>
        <br style="clear:both" />
     </div>
     <div class="clear"></div>
     <div>
            <div style="float:left;padding-right:7px;">
                <a href="/Home/Detail" class="l_blue"><strong>Trang chủ</strong></a>
            </div>    
            <div>
                <form action="/Article/Index" method="post" id="adminForm" name="adminForm"> 
                    <%=Html.DropDownList("ddlArticleCategory", new SelectList(Model.ArticleCategorys, "ID", "Name"), "-- Chọn danh mục --", new { onchange = "document.adminForm.submit();" })%>
                </form>
            </div>
     </div>
      <script type="text/javascript">
          $(document).ready(function() {
          $('.ctn').click(function() {

                  if ($('#pages_none').hasClass('pages_none')) $('#pages_none').removeClass('pages_none').addClass('pages');
                  else $('#pages_none').removeClass('pages').addClass('pages_none');
              });
          });
      </script>
</asp:Content>
